package org.csu.jpetstorespringversion.service.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.csu.jpetstorespringversion.mapper.CategoryMapper;
import org.csu.jpetstorespringversion.mapper.UserMapper;
import org.csu.jpetstorespringversion.model.Category;
import org.csu.jpetstorespringversion.model.User;
import org.csu.jpetstorespringversion.service.CategoryService;
import org.csu.jpetstorespringversion.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Autowired
    CategoryMapper categoryMapper;
    public List<Category> getCategoryList(){
        QueryWrapper<Category> queryWrapper=new QueryWrapper<>();
        queryWrapper.isNotNull("catid");
        List<Category>categories=categoryMapper.selectList(queryWrapper);
        return categories;
    }

    //通过id查看某一个类  select a category by ID
    public Category getCategory(String categoryId){
        QueryWrapper<Category> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("catid",categoryId);
        Category category=categoryMapper.selectOne(queryWrapper);
        return category;
    }
}
